<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>卖家-修改个人信息</title>
<link href="<?php echo $this->_webroot('/user/css/common.css'); ?>" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->_webroot('/user/css/content1.css'); ?>" rel="stylesheet" type="text/css" />
<script src="<?php echo $this->_webroot('/user/js/jquery-1.7.1.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->_webroot('/user/js/common.js'); ?>" type="text/javascript"></script>


 
</head>
<body>
<psp:tags     htmlname='user_topnav1'  iconname='usertopnav1' />
<psp:tags     htmlname='user_topsearch'  iconname='usertopsearch' />

<div class="main">
	<div class="main-left">
    	<div class="title">会员管理中心</div>
        <psp:tags     htmlname='user_menulist'  iconname='usermenulist' />
    </div>
<link href="<?php echo $this->_webroot('/user/css/shoprequest.css'); ?>" rel="stylesheet" type="text/css" />   
    <div class="main-right main_right">
	

            <div class="cont">
                <div class="title_uc"><h3>我的订单</h3></div>               

             <div id="stepTip" class="clearfix">
     <ul class="list_step1 clearfix">
     <li class="now">第一步:<br />设置收货人地址</li>
     <li>第二步:<br />确认订单</li>
     <li style="padding-right:0">第三步:<br />完成</li>
     </ul>
     </div>	  
		<form action="<?php echo $this->_url('user/userorder/');?>?gid=<?php echo implode(',',$goods_id);?>&v=<?php echo implode(',',$order_num);?>" method="post" name="for个人信息" onsubmit="return checkform();">


		<table width="100%" class="form_table">
			<tr class="center"><th colspan="7">收件人地址列表</th></tr>
			<?php if(empty($address_rs)){?>
				<tr><td class="center" colspan="7">没有保存的收货地址</td></tr>
			<?php }?>
			<?php foreach($address_rs as $val){?>
			<tr>
				<td class="center"><input type="radio" name="address_id" value="<?php echo $val['useraddress']['id'];?>" onclick="changeurl(<?php echo $val['useraddress']['id'];?>);" <?php if($val['useraddress']['id']==$address_id){?> checked <?php }?> /></td>
				<td class="center"><?php echo $val['useraddress']['to_user_name'];?></td>
				<td><?php echo $areas_info[0][$val['useraddress']['user_country']]['area_name'];?> <?php echo $areas_info[1][$val['useraddress']['user_province']]['area_name'];?> <?php echo $areas_info[2][$val['useraddress']['user_city']]['area_name'];?> <?php echo $areas_info[3][$val['useraddress']['user_district']]['area_name'];?></td>
				<td><?php echo $val['useraddress']['full_address'];?></td><td class="center"><?php echo $val['useraddress']['zipcode'];?></td>
				<td class="center"><?php echo $val['useraddress']['mobile'];?>/<?php echo $val['useraddress']['telphone'];?></td>
				<td class="center"><?php echo $val['useraddress']['email'];?></td>
			</tr>
			<?php }?>
			<tr>
			    <td class="center"><input type="radio" name="address_id" value="" onclick="newAddress();" <?php if(empty($address_rs)){?> checked <?php }?>/></td>
			    <td class="left" colspan="4">使用其它收货地址</td><td></td><td class="center"></td>
			</tr>
		</table>

		<table width="100%" class="form_table">
			<tr class="center"><th colspan="7">选择支付方式</th></tr>
			<?php if(empty($payment_info)){?>
				<tr><td class="center" colspan="7">没有设置支付方式</td></tr>
			<?php }?>
			
			<tr><td class="center" colspan="7">
            <?php $num=0; foreach($payment_info as $val){?>
			<?php if (isset( $payment[$val['shoppayment']['pay_id']] )) {  $num++;?> 
			<input type="radio" name="data[payid]" value="<?php echo $val['shoppayment']['pay_id'] ;?>" <?php if($num==1) { ?> checked <?php }?>/><?php echo $payment[$val['shoppayment']['pay_id']] ;?>
			<?php }?>
			<?php }?></td>
			</tr>
			
		</table>	

		<table width="100%" class="form_table">
			<tr class="center"><th colspan="2">物流选择</th></tr>
            <tr>
			    <td >详细物流：
                <textarea name="logistics_content" style="width:400px;height:100px"  maxlength="500"   id="keyword_s" ></textarea>				
				</td>
			</tr>			
			<tr>
			    <td >我的物流：
                    <select name="select2" onChange="MM_keyword(this)">
                    <option value='' selected>我的物流</option>
					<?php foreach($my_address_rs as $val ) { $val = $val['userlogistics'];?>
		                <option value='<?php echo '[物流名称:'.$val['name'].';联系人:'.$val['user_name'].';联系电话:'.$val['telphone'].';车牌号:'.$val['carnum'].';价格:'.$val['money'].'元]' ;?>' >
					    <?php echo '[物流名称:'.$val['name'].';联系人:'.$val['user_name'].';联系电话:'.$val['telphone'].';车牌号:'.$val['carnum'].';价格:'.$val['money'].'元]' ;?>
					    </option>
		            <?php } ?>
                    </select>
                    <br/><br/>					
                    商家物流：
                    <select name="select3" onChange="MM_keyword(this)">
                    <option value='' selected>我的物流</option>
					<?php foreach($shop_address_rs as $val ) { $val = $val['userlogistics'];?>
		                <option value='<?php echo '[物流名称:'.$val['name'].';联系人:'.$val['user_name'].';联系电话:'.$val['telphone'].';车牌号:'.$val['carnum'].';价格:'.$val['money'].'元]' ;?>' >
					    <?php echo '[物流名称:'.$val['name'].';联系人:'.$val['user_name'].';联系电话:'.$val['telphone'].';车牌号:'.$val['carnum'].';价格:'.$val['money'].'元]' ;?>
					    </option>
		            <?php } ?>
                    </select>				
				</td>			
			</tr>			
			<tr>
			    <td >总价格：<input type="text" name="logistics_money" value="" maxlength="10"  onchange="if(/\D/.test(this.value)){alert('只能输入数字');this.value='';}"  />元</td>
			</tr>
			
		</table>		
<script language="JavaScript">
<!--
function get_obj(obj){
   return document.getElementById(obj);
}
function MM_keyword(selObj){ //v3.0
  va=selObj.options[selObj.selectedIndex].value
  if (va!=''){
  	if(get_obj('keyword_s').value==''){
		get_obj('keyword_s').value=va;
	}else{
		vb=get_obj('keyword_s').value;
		arr = vb.split(' ');
		for(var i=0;i<arr.length;i++){
			if(arr[i]==va){
				alert(va+",已经存在了,不能雷同");
				return ;
			}
		}
		get_obj('keyword_s').value+=" "+va;
	}
  } 
}
//-->
</script>		

       <table id="newAddress" width="100%" border="0" cellspacing="0">
					<tr>
						<th align="left" width="30%">&nbsp;&nbsp;收货信息</th><th width="70%"><span></span></th>
					</tr>
					<tr><td class="textright">联系人：</td>
						<td align="left"><input type="text" name="data[useraddress][to_user_name]" value="<?php echo  $user_info['to_user_name'];?>" maxlength="20" /></td></tr>
					<tr>
						<td class="textright">所在地区：</td>
						<td>
								<span id="user_country">
								<select name="data[useraddress][user_country]" onchange="areachanged(this.value,0);">
									<option value='0'>选择国家</option>
								 <?php   foreach($areas_info[0] as $v){?>
									<option value="<?php echo  $v['id'];?>" <?php  if($v['id']==$user_info['user_country']){echo 'selected';}?>><?php echo  $v['area_name'];?></option>
								<?php }?>
								</select>
								</span>
								
								<span id="user_province"><?php  if($user_info['user_country']){?>
								<select name="data[useraddress][user_province]"  id="province"  onchange="areachanged(this.value,1);">
									<option value='0'>选择省份</option>
								<?php foreach($areas_info[1] as $v) {
										if($v['parent_id'] == $user_info['user_country']){?>
									<option value="<?php echo  $v['id'];?>" <?php   if($v['id']==$user_info['user_province']){echo 'selected';}?>><?php echo  $v['area_name'];?></option>
								<?php 	}
								}?>
								</select>
								<?php }?>
								</span>
								
								<span id="user_city">
								<?php 	 if($user_info['user_province']){?>
								<select name="data[useraddress][user_city]" onchange="areachanged(this.value,2);">
									<option value='0'>选择城市</option>
								    <?php foreach($areas_info[2] as $v) {
										if($v['parent_id'] == $user_info['user_province']){?>
									<option value="<?php echo  $v['id'];?>" <?php  if($v['id']==$user_info['user_city']){echo 'selected';}?>><?php echo  $v['area_name'];?></option>
								<?php 	}
								}?></select>
								<?php }?>
								</span>
								
								<span id="user_district">
								<?php  if($user_info['user_city']) {?>
								<select name="data[useraddress][user_district]">
									<option value='0'>选择地区</option>
								<?php foreach($areas_info[3] as $v) {
										if($v['parent_id'] == $user_info['user_city']){?>
									<option value="<?php echo  $v['id'];?>" <?php   if($v['id']==$user_info['user_district']){echo 'selected';}?>><?php echo  $v['area_name'];?></option>
								<?php 	}
								}?>
								</select>
								<?php }?>
								</span>
						</td>
					</tr>
					<tr><td class="textright">详细地址：</td>
					<td><input type="text" name="data[useraddress][full_address]" value="<?php echo  $user_info['full_address'];?>" style="width:250px;" maxlength="200" /></td></tr>
					<tr><td class="textright">邮政编码：</td>
					<td><input type="text" name="data[useraddress][zipcode]" value="<?php echo  $user_info['zipcode'];?>" maxlength="6" /></td></tr>
					<tr><td class="textright">手机：</td>
						<td><input type="text" name="data[useraddress][mobile]" value="<?php echo  $user_info['mobile'];?>" maxlength="20" /></td></tr>
					<tr><td class="textright">电话：</td>
						<td><input type="text" name="data[useraddress][telphone]" value="<?php echo  $user_info['telphone'];?>" maxlength="20" /></td></tr>
					<tr><td class="textright">邮箱：</td>
						<td><input type="text" name="data[useraddress][email]" value="<?php echo $user_info['email'];?>" maxlength="40" /></td></tr>
						
						<tr><td class="textright"></td><td align="left"><input type="checkbox" name="data[issave]" value="1" />存储到收货地址列表</td></tr>
					<tr><td></td><td><span>请确认以上的收货信息，以确保能够收到商品！</span><input type=hidden name="data[newadd]" id="newadd" value="0" /></td></tr>
					<tr><td></td><td><span><input type="submit" name="submit" value="提交订单" /></span></td></tr>
				</table>

		</form>			  
			  
			  
            </div>
	
	

        

    </div>
    <div class="clear"></div>
</div>

<div class="footer">
    <psp:tags     htmlname='user_footer_helper'  iconname='userfooterhelper' />

</div>
<script language="JavaScript" src="<?php echo $this->_webroot('servtools/ajax_client/ajax.js');?>"></script>
<script language="JavaScript">
<!--
function newAddress(){
	document.getElementById("newadd").value='1';
	clearaddress();
}


function areachanged(value,type){
	if(value > 0) {	
		ajax("<?php echo $this->_url('user/getareas');?>","POST","value="+value+"&mode=useraddress&pre=user_&type="+type,function(return_text){
			var return_text = return_text.replace(/[\n\r]/g,"");
			if(return_text==""){
				alert("请重新选择!！");
			} else {
				if(type==0) {
					document.getElementById("user_province").innerHTML = return_text;
					show("user_province");
					hide("user_city");
					hide("user_district");
				} else if(type==1) {
					document.getElementById("user_city").innerHTML = return_text;
					show("user_city");
					hide("user_district");
				} else if(type==2) {
					document.getElementById("user_district").innerHTML = return_text;
					show("user_district");
				}
			}
		});
	} else {
		if(type==2) {
			hide("user_district");
		} else if(type==1) {
			hide("user_district");
			hide("user_city");
		} else if(type==0) {
			hide("user_district");
			hide("user_city");
			hide("user_province");
		}
	}
}

function getallpay(type){
	var area_id = document.getElementById('province').value;
	var goods_id = <?php echo $goods_info['goods']['id'];?>;
	var goods_num = <?php echo $order_num;?>;
	ajax("do.php?act=gettransportprice","POST","area_id="+area_id+"&goods_id="+goods_id+"&goods_num="+goods_num+"&type="+type,function(data){
		document.getElementById("order_amount").value=parseInt(parseInt(<?php echo $goods_info['goods']['goods_price'];?>)*goods_num+parseInt(data));
		document.getElementById("allpay").innerHTML=document.getElementById("order_amount").value;
		document.getElementById("transportprice").innerHTML=data;
		document.getElementById("transport_price").value=data;
	});
}
function hide(id) {
	document.getElementById(id).style.display = 'none';
}

function show(id) {
	document.getElementById(id).style.display = '';
}



function checkform(){
	var to_user_name = document.getElementsByName('data[useraddress][to_user_name]')[0];
	if(to_user_name.value==''){
		alert('请填写收件人姓名');
		return false;
	}

	var province = document.getElementsByName('data[useraddress][user_province]')[0];
	if(province.value==0){
		alert('请选择收件人省份');
		return false;
	}

	var city = document.getElementsByName('data[useraddress][user_city]')[0];
	if(city.value==0){
		alert('请选择收件人城市');
		return false;
	}

	var district = document.getElementsByName('data[useraddress][user_district]')[0];
	if(district.value==0){
		alert('请选择收件人地区');
		return false;
	}

	var full_address = document.getElementsByName('data[useraddress][full_address]')[0];
	if(full_address.value==''){
		alert('请填写收件人详细地址');
		return false;
	}

	var zipcode = document.getElementsByName('data[useraddress][zipcode]')[0];
	if(zipcode.value==''){
		alert('请填写邮政编码');
		return false;
	}

	var email = document.getElementsByName('data[useraddress][email]')[0];
	var user_email_reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if(!email.value=='' && !user_email_reg.test(email.value)){
		alert('您填写的邮箱格式不正确');
		return false;
	}

	var user_mobile = document.getElementsByName('data[useraddress][mobile]')[0];
	var reg = /^\d+(\.d+)?$/;

	var user_telphone = document.getElementsByName('data[useraddress][telphone]')[0];
	var tel_reg=/^([0-9]|[-])+$/g ;

	if(user_mobile.value=='' && user_telphone.value=='') {
		alert('对不起，电话和手机至少填写一项。');
		return false;
	} else if(!user_mobile.value=='' && !reg.test(user_mobile.value)) {
		alert('对不起，您输入的手机号码错误。');
		return false;
	} else if(!user_telphone.value=='' && !tel_reg.test(user_telphone.value)) {
		alert('对不起，您输入的电话号码错误。');
		return false;
	}else {
		return true;
	}
}


function changeurl(v){
	var re = /&address_id=[0-9]+/g;
	var str = location.href.replace(re,"");
	var str1 = str.replace("<?php echo $url_param;?>","");
	var url = str1.replace("?","")+"?&address_id="+v+"<?php echo $url_param;?>";
	location.href = url;
}

function clearaddress() {
	areachanged(1,0);
	var to_user_name = document.getElementsByName('data[useraddress][to_user_name]')[0];
	to_user_name.value="";
	var full_address = document.getElementsByName('data[useraddress][full_address]')[0];
	full_address.value="";
	var zipcode = document.getElementsByName('data[useraddress][zipcode]')[0];
	zipcode.value="";
	var mobile = document.getElementsByName('data[useraddress][mobile]')[0];
	mobile.value="";
	var telphone = document.getElementsByName('data[useraddress][telphone]')[0];
	telphone.value="";
	var email = document.getElementsByName('data[useraddress][email]')[0];
	email.value="";
	var address_id = document.getElementsByName('data[useraddress][address_id]')[0];
	address_id.value="";
}
//-->
</script>
</body>
</html>